import { Component, OnInit } from '@angular/core';
import { SplitterOrientation } from 'ng-devui/splitter';
import { BroadcastService } from 'src/app/services/broadcast.service';
import { DialogService } from 'ng-devui/modal';
import { MateDataService } from 'src/app/services/mate_data.service';
import { SessionService } from 'src/app/services/session.service';
import { Router } from '@angular/router';

@Component({
    selector: 'app-main-page',
    templateUrl: './main-page.component.html',
    styleUrls: ['./main-page.component.scss']
})
export class MainPageComponent implements OnInit {

    title = 'transformExcel';
    // splitter input
    orientation: SplitterOrientation = 'horizontal';
    splitBarSize = '2px';
    disabledBarSize = '1px';

    // splitter pane input
    size = '15%';
    minSize = '15%';
    maxSize = '15%';
    collapsed = false;
    isPaneShrink = false;
    hoverCard: Array<any> = [];

    filesList: any = [];
    isUserInfoPage:boolean = false;

    private _handler1: any = [];

    constructor(
        private broadcastSrv:BroadcastService,
        private sessionService:SessionService,
        private router:Router,
    ) {
        this.broadcastSrv.on('changeRightInfo').subscribe(res => {
            if(res){
                this.isUserInfoPage = res.isUserInfoPage;
            }
        });
    }

    ngOnInit(): void {
        let user = this.sessionService.getSessionValue('user')
        if(!user){
            this.router.navigate(['login'])
        }
    }


    sizeChange(size) {
    }

    collapsedChange(event) {
        console.log(event);
        this.collapsed = event;
    }

    selectItem(selectedItem) {
        this.collapsedChange(false);
    }

    paneShrinkStatus(status) {
        this.isPaneShrink = status;
    }

    isChildrenActive(item) {
        const isActive = item.children && item.children.some((child) => child.active);
        return isActive;
    }
}
